// List组件的展示组件
import React from 'react'

export default function List(props) {
  return (
    <div>
      <hr />
      <input
        type="text"
        onKeyDown={(e) => {
          if (e.keyCode !== 13) return
          const value = e.target.value
          props.addItem(value)
        }}
      />

      <ul>
        {props.list.map((item, index) => (
          <li key={index}>{item}</li>
        ))}
      </ul>
    </div>
  )
}
